<?php
ini_set('display_errors','1'); ini_set('display_startup_errors','1');  
include_once(ROOT_PATH."classes/dao/vote.class.php");
$vote = new Vote();
include_once(ROOT_PATH."classes/dao/procategories.class.php");
$procategories = new ProductCategories();
#product
include_once(ROOT_PATH."classes/dao/products.class.php");
$products = new Products();
$templateFile = "productdetail.tpl.html";
$slug = $request->element('slug','');
$id = $request->element('id',0);
if ($id){
	$productItem = $products->getObject($id);
	if ($productItem) {
		$cat = $productItem->getCategory();
		$parentItem=$procategories->getParentAllFromCid($cat);
		$activeleft=$parentItem[0];
		$template->assign('activeleft',$activeleft);
		//$subItem=$procategories->getObject($activeleft);
		$template->assign('productItem',$productItem);
		$id=$productItem->getId();
		$orderproducItems = $products->getObjects(1,"status =1 AND category=$cat AND id!=$id",array('position'=>'ASC'),8);
		$template->assign('orderproducItems',$orderproducItems);
		
		$randomproducItems = $products->getObjects(1,"status =1 AND id!=$id",array('position'=>'ASC'),8);
		$template->assign('randomproducItems',$randomproducItems);		
		$proCatItem= $procategories->getObject($cat);
		$pageName = $productItem->getName($lang);
		$template->assign('pageName',$pageName);
		$template->assign('proCatItem',$proCatItem);
		$template->assign('vote',$vote);
		//$template->assign('subItem',$subItem);
		// lay các cấp danh mục
		$patParentItems = $procategories->getPathParrent($cat);
		$template->assign('patParentItems',$patParentItems);
		
	}
}
$order=array('id'=>'DESC');
$template->assign('products',$products);
$template->assign('order',$order);
#end product
#dung chung
include_once(ROOT_PATH."modules/framework.module.php");
# active
 $active='san-pham';
 $template->assign('active',$active);
?>